<?php

class Email_model extends CI_Model{

	function sendEmails($userid){
		$articles=$this->articles_model->getArticlesByUserID($userid);

		$emails = $this->articles_model->getSubscribersEmails($userid);
		if($emails){
			$this->load->library('email');
			$this->email->set_newline("\r\n");
			$this->email->from('playbacktddd27@gmail.com','Playback no-reply');
			$this->email->to($emails);
			$this->email->subject("A new article has been written by ".$this->user_model->getUsername($userid));
			$this->email->message(base_url()."index.php/articles/id/".$articles[0]->articleID);
			$this->email->send();
		}

	}
}